Repository navigation
Fix any/all for int8 and uint8 on Metal - #4755
Merged
Merged
Conversation
zcbenz
force-pushed
the
fix/metal-any-int8
branch
from
October 25, 2026 09:58
ff80efc to
f1887b0
Compare
zcbenz
approved these changes
Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I used AI to help me find this bug. All code is mine and I did all of the testing.
mx.anyis wrong on Metal for int8/uint8 when the nonzero values are even:remap_reduce_typessends every 1-byte dtype to the bool and/or kernels, so int8/uint8 bytes get read as Metalbool. Metal assumes a bool byte is 0 or 1, and several of the kernels only test the low bit, so a 2 reads as false.mx.allhappens to come out right but reads the same bad data. Been there since #1607.I added
test_and_or_small_ints: even int8/uint8 values over the all, row, multi-axis and column paths. 8 subtests fail on main on Metal, all pass with the fix. Existing tests only use 0 and 1 so never hit this.Full Python suite passes apart from
test_init_reduce_large_output, which errors on main too: it asks for a 4 GiB buffer and the GitHub runner caps at 3.5 GiB, so you'll see the same on a smaller Mac. I ran both wheels through 108 any/all cases on int8, uint8 and bool. Main gets 8 wrong and the patched one gets 0.Perf: the int8 kernels are within noise of bool, but that was on CI runners' that vary 1.1 to 2x even on untouched code.
Doesn't fix a uint8 array viewed as
bool_, since a bool input still gets the bool kernel.